﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeFile="InqueryPesertaList.aspx.cs" Inherits="Training.Web.Lists.Administration.Catalog.InqueryPesertaList" %>

<asp:Content ID="ctnBody" ContentPlaceHolderID="body" runat="server">
    <link type="text/css" rel="stylesheet" href="<%= ResolveUrl("~/styles/ui.jqgrid.css") %>" />
    <script type="text/javascript" src="<%= ResolveUrl("~/scripts/i18n/grid.locale-id.js") %>"></script>
    <script type="text/javascript" src="<%= ResolveUrl("~/scripts/jquery.jqGrid.min.js") %>"></script>
    <script src="<%= ResolveUrl("~/scripts/jquery.msgBox.v1.js") %>" type="text/javascript"></script>
    <script src="<%= ResolveUrl("~/scripts/chosen/chosen.jquery.min.js") %>" type="text/javascript"></script>
    <link href="<%= ResolveUrl("~/styles/chosen/chosen.min.css") %>" rel="stylesheet"
        type="text/css" />
    <div class="page-full-width cf">
        <div class="content-module">
          <%--  <div class="content-module-heading cf">
                <h3 class="fl">
                    Role</h3>
                <span class="fr expand-collapse-text">Click to collapse</span> <span class="fr expand-collapse-text initial-expand">
                    Click to expand</span>
            </div>--%>
            <!-- end content-module-heading -->
            <div class="content-module-main">
                <div>
                    <table border="0">
                        <tr>
                            <td>
                                NIK
                            </td>
                            <td>
                                :
                            </td>
                            <td>
                                <table border="0">
                                    <tr>
                                        <td>
                                            <asp:DropDownList ID="ddlNIK" runat="server" Width="300">
                                            </asp:DropDownList>
                                        </td>
                                        <td style="padding-left: 50px;">
                                            Jabatan
                                        </td>
                                        <td style="padding-left: 10px;">
                                            :
                                        </td>
                                        <td>
                                            <asp:TextBox ReadOnly="true" ID="txtJabatan" runat="server" Width="500"></asp:TextBox>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Nama Peserta
                            </td>
                            <td>
                                :
                            </td>
                            <td>
                                <table border="0">
                                    <tr>
                                        <td>
                                            <asp:TextBox ReadOnly="true" ID="txtNamaPeserta" runat="server" Width="300"></asp:TextBox>
                                        </td>
                                        <td style="padding-left: 45px;">
                                            Cabang
                                        </td>
                                        <td style="padding-left: 10px;">
                                            :
                                        </td>
                                        <td>
                                            <asp:TextBox ReadOnly="true" ID="txtBagian" runat="server" Width="500"></asp:TextBox>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Departemen
                            </td>
                            <td>
                                :
                            </td>
                            <td>
                                <table border="0">
                                    <tr>
                                        <td>
                                            <asp:TextBox ReadOnly="true" ID="txtDepartemen" runat="server" Width="300"></asp:TextBox>
                                        </td>
                                        <td style="padding-left: 45px;">
                                            Lokasi
                                        </td>
                                        <td style="padding-left: 18px;">
                                            :
                                        </td>
                                        <td>
                                            <asp:TextBox ReadOnly="true" ID="txtLokasi" runat="server" Width="500"></asp:TextBox>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="3">
                                <div style="text-align: right; padding-top: 10px;">
                                    <button id="btnProcess" type="button">
                                        Proses</button>
                                </div>
                            </td>
                        </tr>
                    </table>
                </div>
                <br />
                <table id="table" class="scroll" cellpadding="0" cellspacing="0">
                </table>
                <div id="pager" class="scroll">
                </div>
                <br />
                <div id="dialog" title="Default dialog">
                </div>
            </div>
            <!-- end content-module-main -->
        </div>
    </div>
    <script type="text/javascript">
        $(document).ready(function () {
            $('#<%= ddlNIK.ClientID %>').chosen({ placeholder_text_single: "-- pilih NIK --" });

            $('#<%= ddlNIK.ClientID %>').change(function () {

                $('#<%= txtNamaPeserta.ClientID %>').val('');
                $('#<%= txtBagian.ClientID %>').val('');
                $('#<%= txtDepartemen.ClientID %>').val('');
                $('#<%= txtJabatan.ClientID %>').val('');
                $('#<%= txtLokasi.ClientID %>').val('');
                var handlerUrl = '<%= ResolveUrl("~/AjaxHandler/Loaddata/Administration/catalog/KaryawanLoadHandler.ashx") %>';
                var NIK = $("#<%= ddlNIK.ClientID %> option:selected").val();

                if (NIK != "") {
                    $.ajax({
                        type: 'POST',
                        url: handlerUrl + "?method=getbyid&NIK=" + NIK,
                        contentType: 'application/json',
                        dataType: 'json',
                        success: function (datas) {
                            $('#<%= txtNamaPeserta.ClientID %>').val(datas.NamaKaryawan);
                            $('#<%= txtBagian.ClientID %>').val(datas.Cabang);
                            $('#<%= txtDepartemen.ClientID %>').val(datas.Departemen);
                            $('#<%= txtJabatan.ClientID %>').val(datas.Jabatan);
                            $('#<%= txtLokasi.ClientID %>').val(datas.Lokasi);
                        },
                        error: function () {
                            $.msgBox("Error load peserta  !", null, { title: "Pesan Error" });
                        }
                    });

                    //END
                }

                var NIK = $('#<%= ddlNIK.ClientID  %> option:selected').val();
                if (NIK == "")
                    NIK = 0;

                var handlerUrl = '<%= ResolveUrl("~/AjaxHandler/Administration/Catalog/Pelatihanhandler.ashx") %>';
                $("#table").jqGrid('setGridParam', { url: handlerUrl + '?method=getdatabypeserta&NIK=' + NIK });
                $("#table").trigger("reloadGrid");

            });

        });
    </script>
    <script type="text/javascript">
        $("#btnProcess").click(function () {
            var NIK = $('#<%= ddlNIK.ClientID  %> option:selected').val();
            if (NIK == "")
                NIK = 0;

            var handlerUrl = '<%= ResolveUrl("~/AjaxHandler/Administration/Catalog/Pelatihanhandler.ashx") %>';
            $("#table").jqGrid('setGridParam', { url: handlerUrl + '?method=getdatabypeserta&NIK=' + NIK });
            $("#table").trigger("reloadGrid");
        });
    </script>
    <script type="text/javascript">
        $("#btnProcess").button({ icons: { primary: "ui-icon-search"} });
    </script>
    <script type="text/javascript">

        var handlerUrl = '<%= ResolveUrl("~/AjaxHandler/Administration/Catalog/Pelatihanhandler.ashx") %>';

        var NIK = $('#<%= ddlNIK.ClientID  %> option:selected').val();
        if (NIK == "")
            NIK = 0;

        $('#table').jqGrid({
            url: handlerUrl + '?method=getdatabypeserta&NIK=' + NIK,
            datatype: 'json',
            colNames: ['ID', 'Nama Pelatihan', 'Tgl. Mulai', 'Tgl. Akhir', 'Tempat Pelatihan', 'Pembicara'],
            colModel: [
                { name: 'PelatihanID', key: true, hidden: true, index: 'PelatihanID', width: 60 },
                { name: 'NamaPelatihan', index: 'NamaPelatihan', align: 'left', width: 200, searchoptions: { sopt: ['cn', 'eq']} },
                { name: 'TglPelatihan', index: 'TglPelatihan', align: 'center', width: 150, search: false, formatter: 'date', formatoptions: { newformat: 'd M Y'} },
                { name: 'TglAkhirPelatihan', index: 'TglAkhirPelatihan', align: 'center', width: 150, search: false, formatter: 'date', formatoptions: { newformat: 'd M Y'} },
                { name: 'TempatPelatihan', index: 'TempatPelatihan', align: 'left', width: 200, searchoptions: { sopt: ['cn', 'eq']} },
                { name: 'Pembicara.NamaPembicara', index: 'NamaPembicara', align: 'left', width: 200, searchoptions: { sopt: ['cn', 'eq']} }
           	],
            rownumbers: true,
            rowNum: 10,
            id: 'PelatihanID',
            multiselect: false,
            rowList: [5, 10, 15, 20],
            pager: '#pager',
            sortname: 'NamaPelatihan',
            sortorder: "asc",
            viewrecords: true,
            jsonReader: { repeatitems: false },
            width: 1000,
            height: '100%',
            caption: 'Pelatihan',
            ajaxGridOptions: { cache: false }
        });

        $("#table").jqGrid('navGrid', '#pager', { edit: false, add: false, del: false, searchtext: 'Search', refreshtext: 'Refresh' },
        {}, {}, {}, { closeOnEscape: true, multipleSearch: true, closeAfterSearch: true });

       
    
    </script>
</asp:Content>
